﻿using System;
using Game1942.Library.Background;
using Game1942.Library.Background.Bodies;
using Game1942.Library.FlightPlans;
using Game1942.Library.Items;
using Game1942.Library.Weapons;

namespace Game1942.Library.Planes
{
    public class Caza : Aircraft
    {
        public Caza()
        {
            energy = new EnergyCounter(Constants.Caza.Energy);
            damage = Constants.Caza.Damage;
            score = Constants.Caza.Score;
            manageTurn = new TurnManager(Constants.Caza.Speed, Constants.Caza.Rate);
            playerTeam = Constants.Caza.PlayerTeam;

            flightPlan = new Vstrategy(Constants.Caza.Speed);

            position.SetBody(new Square(Constants.Caza.Width, Constants.Caza.Height));
        }

        public Caza(Point aPosition): this()
        {
            base.SetPosition(aPosition);
        }

        public override void Shoot()
        {
            var torpedo = new Torpedo(new Point(ActualPosition.X + 30, ActualPosition.Y + 90),playerTeam, false);
            Driver.Instance.AddLiveUnit(torpedo, Constants.Torpedo.Width, Constants.Torpedo.Height, Constants.Torpedo.ViewNameDown); 
        }

        public override void Destroy()
        {
            position.Deallocate();  // If it is on the map, get rid of it
            Alive = false;
            Driver.Instance.AddLiveUnit(new EnergyTank(position.Value), Constants.EnergyTank.Width, Constants.EnergyTank.Height,
                Constants.EnergyTank.ViewName);
        }
    }
}
